<?php


namespace app\plugins\goods\admin\model;


use think\model\concern\SoftDelete;

class GoodsTags extends \app\common\plugins\PluginModel
{
    use SoftDelete;

    protected $name = 'goods_tags';

    protected $createTime = 'createtime';

    protected $updateTime = false;

    protected $deleteTime = 'deletetime';

    protected $defaultSoftDelete = null;

    protected $schema = [
        'id' => 'int',
        'title' => 'string',
        'sort' => 'int',
        'icon' => 'string',
        'createtime' => 'int',
        'deletetime' => 'int',
        'status' => 'int',
    ];

    protected $submitField = [
        'status' => 'int',
    ];
    protected $append = [
        'icon_path'
    ];

    public function getIconPathAttr($value,$data){
        return get_file_path($data['icon']);
    }

    public function scopeStatus($query,bool $normal=false){
        $query->where('status',(int)$normal);
    }
}